package com.orhon.smartcampus.modules.base.entity;

import lombok.Data;

import javax.persistence.*;

import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

import java.sql.Timestamp;
import java.util.Date;

import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.Where;

@Setter
@Getter
@EqualsAndHashCode
@Entity
@Table(name = "base_regions", schema = "smartcloud", catalog = "")
public class Regions {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id", nullable = false)
    private Long id;
    @Column(name = "region_slug", nullable = false, length = 191)
    private String regionSlug;
    @Column(name = "region_name", nullable = true)
    private String regionName;
    @Column(name = "level", nullable = false)
    private Integer level;
    @Column(name = "region_order", nullable = false)
    private Integer regionOrder;
    @Column(name = "created_at", nullable = true)
    private Date createdAt;
    @Column(name = "updated_at", nullable = true)
    private Date updatedAt;
    @Column(name = "deleted_at", nullable = true)
    private Date deletedAt;
    
    //"父级地区"  
  	@ManyToOne
  	@JoinColumn(name = "parent_id")
    @Where(clause = "ISNULL(deleted_at)")
  	@NotFound(action=NotFoundAction.IGNORE)
  	private Regions parentRegions;
}
